package com.globant;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.globant.profy.model.Languages;
import com.globant.profy.model.Permisos;
import com.globant.profy.model.User;

public class prueba2 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ApplicationContext ctx = new ClassPathXmlApplicationContext("/applicationContext-persist-SQL.xml");
		UserDAOImplementation dao=(UserDAOImplementation) ctx.getBean("userDao");
		Permisos perm=new Permisos("admin");
		perm.setInfo("permiso otorgado");
		User user = new User("eaea@gmail.com");
		user.setName("ea");
		user.setEnabled(1);
		user.setPermission(perm);
		Languages esp=new Languages();
		esp.setIdioma("Spanish");		
		List<Languages>languages=new ArrayList<Languages>();
		languages.add(esp);
		Languages eng=new Languages();
		eng.setIdioma("English");
		languages.add(eng);
		user.setLanguages(languages);
		dao.createUser(user);
		List<User> users=dao.getUserByCriteria("java dev");
		System.out.println("Cantidad"+users.size());
		System.out.println(dao.getUserByEmail("eaea@gmail.com").getPermission().getTipo());
		System.out.println("FINNN");
		List<Languages> list = user.getLanguages();
		System.out.println(list);
	}
}
